Xbasic

STRUCT_GET Function

STRUCT_GET() is deprecated and slated for removal in a future release.

Syntax

Data as B = STRUCT_GET(P structure)

Arguments

structure

A pointer to a structure.

Description

Converts a packed structure to a blob.

Discussion

STRUCT_GET() converts the contents of a packed structure into a blob. This is useful for writing data to binary files, preserving binary data in a memo, and putting data on the clipboard.

Example

This following snippet of code reads the bitmap header structure from a bitmap file.

declarestruct BITMAPFILEHEADER C2Type,L1Size,W2Reserved,L1OffBits
? name of bitmap file is stored in a character variable
dim shared bitmapfilename as C
? open the bitmap file
f = file.open(bitmapfilename,FILE_RO_SHARED)
? use STRUCTURE_set with no blob to create a structure
bitmapfile = struct_set("BITMAPFILEHEADER")
? which we then use to create a blob
bitmapfiledata = struct_get(bitmapfile)
?which we use to determine the size we need to read
bitmapfiledata = f.readb(bitmapfiledata.SIZE() )
? convert the blob to the structure
bitmapfile = struct_set("BITMAPFILEHEADER",bitmapfiledata)
? close the file
f.close()

See Also